import java.util.ArrayList;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 晓星航
 * Date: 2023-01-25
 * Time: 16:19
 */
class MyArrayList<E> {
    private Object[] elementData;//数组
    private int usedSize;//代表有效的数据个数

    private static final  Object[] DEFAULTCAPACITY_EMPTY_ELEMENTDATA = {};

    public MyArrayList() {
        this.elementData = DEFAULTCAPACITY_EMPTY_ELEMENTDATA;
    }

    public MyArrayList(int capacity) {
        //对参数进行判断
        if(capacity > 0) {
            this.elementData = new Object[capacity];
        } else if(capacity == 0) {
            this.elementData = new Object[0];
        } else {
            throw new IllegalArgumentException("初始化的容量不能为负数");
        }
    }
}
public class TestDemo {
    public static void main(String[] args) {

    }
    public static void main1(String[] args) {
        ArrayList<String> list = new ArrayList<>(13);
        list.add("hello");
        list.add("xxh");
        list.add("xyh");
        list.add("lol");
        list.add("coc");
        System.out.println(list.subList(1, 3));
        System.out.println(list);
    }
}
